package com.situ.skymall.admin.api.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.situ.model.User;
import com.situ.model.UserAddress;
import com.situ.utils.JsonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "skymall-gateway", contextId = "skymall-user-api")
//@FeignClient(name = "skymall-user-api")
public interface UserFeignService {

    /**
     * 查询所有用户
     */
    @GetMapping("/api/v1/user/findAll")
    JsonResult<Page<User>> findAll(
            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") int pageSize,
            @RequestParam(value = "username", required = false) String username,
            @RequestParam(value = "phone", required = false) String phone,
            @RequestParam(value = "roleType", required = false) Integer roleType);
    /**
     * 根据用户id查询用户
     */
    @GetMapping("/api/v1/user/findById/{id}")
    JsonResult<User> getUserById(@PathVariable("id") Integer id);

    /**
     * 根据用户名查询用户
     */
    @GetMapping("/api/v1/user/findByUsername/{username}")
    JsonResult<User> getUserByUsername(@PathVariable("username") String username);

    /**
     * 修改用户状态
     */
    @PutMapping("/api/v1/user/status/{id}/{status}")
    JsonResult<String> updateStatus(@PathVariable("id") Integer id, @PathVariable("status") Integer status);

    /**
     * 添加用户
     */
    @PostMapping("/api/v1/user/add")
    JsonResult<String> addUser(@RequestBody User user);

    /**
     * 修改用户角色
     */
    @PutMapping("/api/v1/user/role/{id}/{roleType}")
    JsonResult<String> updateRoleType(@PathVariable("id") Integer id, @PathVariable("roleType") Integer roleType);

    /**
     * 用户信息更新
     */
    @PutMapping("/api/v1/user/update")
    JsonResult<String> updateUser(@RequestBody User user);

    /**
     * 用户信息删除
     */
    @DeleteMapping("/api/v1/user/delete/{id}")
    JsonResult<String> deleteUser(@PathVariable("id") Integer id);

    /**
     * 用户头像上传
     */
    @PostMapping(value = "/api/v1/user/avatar", consumes = "multipart/form-data")
    JsonResult<String> uploadAvatar(@RequestPart("file") byte[] file);

    /**
     * 获取用户的所有地址
     */
    @GetMapping("/api/v1/address/list/{userId}")
    JsonResult<List<UserAddress>> getAddressListByUserId(@PathVariable("userId") Integer userId);

    /**
     * 获取用户的默认地址
     */
    @GetMapping("/api/v1/address/default/{userId}")
    JsonResult<UserAddress> getDefaultAddress(@PathVariable("userId") Integer userId);

    /**
     * 设置默认地址
     */
    @PutMapping("/api/v1/address/default")
    JsonResult<String> setDefaultAddress(@RequestParam("userId") Integer userId, @RequestParam("addressId") Integer addressId);

    /**
     * 新增用户地址
     */
    @PostMapping("/api/v1/address/add")
    JsonResult<String> addAddress(@RequestBody UserAddress userAddress);

    /**
     * 修改用户地址
     */
    @PutMapping("/api/v1/address/update")
    JsonResult<String> updateAddress(@RequestBody UserAddress userAddress);

    /**
     * 删除用户地址
     */
    @DeleteMapping("/api/v1/address/delete/{id}")
    JsonResult<String> deleteAddress(@PathVariable("id") Integer id);
}
